package com.eascs.web.o2o.web.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.eascs.common.util.UrlUtil;
import com.eascs.site.view.ViewContext;
import com.eascs.tag.MenuTag;
import com.eascs.web.o2o.web.common.BaseMasterViewController;
import com.eascs.web.o2o.web.form.SmsForm;

@Controller
@RequestMapping("/sms")
public class SmsController extends BaseMasterViewController{
	
	@Override
	public void preHandle() {
		super.preHandle();
		ViewContext.put(MenuTag.CURRENT_MENU_CODE, "systemSettings");
	}
	
	@RequestMapping(value = "/smsindex")
	public String smsIndex(SmsForm smsForm){
		ViewContext.put(MenuTag.CURRENT_MENU_CODE, "sms");
		String o2ourl="/restsms/sms";
		if(smsForm != null ){
			String requestId = smsForm.getRequestId() == null ? "" : smsForm.getRequestId();
			String systemCode = smsForm.getSystemCode() == null ? "" : smsForm.getSystemCode();
			String receiveTelphone = smsForm.getReceiveTelphone() == null ? "" : smsForm.getReceiveTelphone();
			String startTime = smsForm.getStartTime() == null ? null : smsForm.getStartTime();
			String endTime = smsForm.getEndTime() == null ? null : smsForm.getEndTime();
			String status = smsForm.getStatus() == null ? "" : smsForm.getStatus();
			String content = smsForm.getContent() == null ? "" : smsForm.getContent();
			
			o2ourl = UrlUtil.appendUrl(o2ourl, "requestId", requestId);
			o2ourl = UrlUtil.appendUrl(o2ourl, "systemCode", systemCode);
			o2ourl = UrlUtil.appendUrl(o2ourl, "receiveTelphone", receiveTelphone);
			o2ourl = UrlUtil.appendUrl(o2ourl, "startTime", startTime);
			o2ourl = UrlUtil.appendUrl(o2ourl, "endTime", endTime);
			o2ourl = UrlUtil.appendUrl(o2ourl, "status", status);
			o2ourl = UrlUtil.appendUrl(o2ourl, "content", content);
			o2ourl = o2ourl + "&index=";
		}else{
			o2ourl = o2ourl + "?index=";
		}
		ViewContext.put("vo", smsForm);
		ViewContext.put("o2ourl", o2ourl);
		return "sms/smsList";
	}
}
